package com.example.idlefish.GoodsInfo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.idlefish.GoodsInfo.ActivityContract.ToHomePageContract
import com.example.idlefish.GoodsInfo.ActivityContract.ToOrderActivityContract
import com.example.idlefish.GoodsInfo.pojo.BuyInfo
import com.example.idlefish.PublicModule.CommonUtil
import com.example.idlefish.databinding.GoodBuySuccessBinding

class GoodBuySuccessActivity : AppCompatActivity()  {
    private lateinit var binding: GoodBuySuccessBinding
    private val homeLauncher = registerForActivityResult(ToHomePageContract()){
        result->
    }
    private val orderLauncher = registerForActivityResult(ToOrderActivityContract()){
        result->
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = GoodBuySuccessBinding.inflate(layoutInflater)
        setContentView(binding.root)
        val info = CommonUtil.getSerializable(intent, "buyInfo", BuyInfo::class.java)
        binding.buttonMyPurchase.setOnClickListener {
            orderLauncher.launch(info)
        }
        binding.buttonHome.setOnClickListener {
            homeLauncher.launch(Unit)
        }
    }



}